<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans,zh-hk,en,fr-FR,ru,de,ja,id,ko,default">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  
    
      
    

    
  

  

  
    
      
    

    
  

  
    
      
    

    
  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Monda:300,300italic,400,400italic,700,700italic|Roboto Slab:300,300italic,400,400italic,700,700italic|Lobster Two:300,300italic,400,400italic,700,700italic|PT Mono:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Android,Activity,活动传递对象,活动传递 List," />





  <link rel="alternate" href="http://blog.csdn.net/qq_21265915/rss/list" title="WinterSmileSB101 的个人房间" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/images/myHeadImg.jpeg?v=5.1.0" />






<meta name="description" content="版权声明：本文为 wintersmilesb101 -（个人独立博客– http://wintersmilesb101.online 欢迎访问）博主原创文章，未经博主允许不得转载。

现在转眼都十三了，大家都工作了，自己确还没有在家里闲得慌于是就做个App，谁知道就遇到了Activity间传递实例以及List数据的问题。网上同类型的文章很多，我写只是为了做个笔记预防忘记（其他的我觉得进入不了状态">
<meta property="og:type" content="article">
<meta property="og:title" content="17开年第一篇Activity之间传递 List<T> 以及 T 对象类型数据的方法">
<meta property="og:url" content="http://WinterSmileSB101.online/2017/03/22/17开年第一篇活动传递对象/index.html">
<meta property="og:site_name" content="WinterSmileSB101 的个人房间">
<meta property="og:description" content="版权声明：本文为 wintersmilesb101 -（个人独立博客– http://wintersmilesb101.online 欢迎访问）博主原创文章，未经博主允许不得转载。

现在转眼都十三了，大家都工作了，自己确还没有在家里闲得慌于是就做个App，谁知道就遇到了Activity间传递实例以及List数据的问题。网上同类型的文章很多，我写只是为了做个笔记预防忘记（其他的我觉得进入不了状态">
<meta property="og:image" content="http://img.blog.csdn.net/20170209150029848?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjEyNjU5MTU=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center">
<meta property="og:image" content="http://img.blog.csdn.net/20170209150034832?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjEyNjU5MTU=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center">
<meta property="og:updated_time" content="2017-03-22T07:31:03.889Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="17开年第一篇Activity之间传递 List<T> 以及 T 对象类型数据的方法">
<meta name="twitter:description" content="版权声明：本文为 wintersmilesb101 -（个人独立博客– http://wintersmilesb101.online 欢迎访问）博主原创文章，未经博主允许不得转载。

现在转眼都十三了，大家都工作了，自己确还没有在家里闲得慌于是就做个App，谁知道就遇到了Activity间传递实例以及List数据的问题。网上同类型的文章很多，我写只是为了做个笔记预防忘记（其他的我觉得进入不了状态">
<meta name="twitter:image" content="http://img.blog.csdn.net/20170209150029848?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjEyNjU5MTU=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"right","display":"post","offset":12,"offset_float":0,"b2t":true,"scrollpercent":true},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '6376853978663093000',
      author: 'WinterSmileSB101'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://WinterSmileSB101.online/2017/03/22/17开年第一篇活动传递对象/"/>





  <title> 17开年第一篇Activity之间传递 List<T> 以及 T 对象类型数据的方法 | WinterSmileSB101 的个人房间 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  














  
  
    
  

  <div class="container sidebar-position-right page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">WinterSmileSB101 的个人房间</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <h1 class="site-subtitle" itemprop="description">胆小认生，不易相处</h1>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益404
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocapitalize="off" autocomplete="off" autocorrect="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://WinterSmileSB101.online/2017/03/22/17开年第一篇活动传递对象/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="WinterSmileSB101">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="http://on792ofrp.bkt.clouddn.com/17-3-22/29073846-file_1490159480452_d2de.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="WinterSmileSB101 的个人房间">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
            
            
              
                17开年第一篇Activity之间传递 List<T> 以及 T 对象类型数据的方法
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-03-22T15:25:09+08:00">
                2017-03-22
              </time>
            

            
              <span class="post-meta-divider">|</span>
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-check-o"></i>
              </span>
              
                <span class="post-meta-item-text">更新于</span>
              
              <time title="更新于" itemprop="dateModified" datetime="2017-03-22T15:31:03+08:00">
                2017-03-22
              </time>
            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Android/" itemprop="url" rel="index">
                    <span itemprop="name">Android</span>
                  </a>
                </span>

                
                
                  ， 
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Android/Android-实践/" itemprop="url" rel="index">
                    <span itemprop="name">Android 实践</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/03/22/17开年第一篇活动传递对象/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/03/22/17开年第一篇活动传递对象/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
             <span id="/2017/03/22/17开年第一篇活动传递对象/" class="leancloud_visitors" data-flag-title="17开年第一篇Activity之间传递 List<T> 以及 T 对象类型数据的方法">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数 </span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <blockquote>
<p>版权声明：本文为 wintersmilesb101 -（个人独立博客– <a href="http://wintersmilesb101.online">http://wintersmilesb101.online</a> 欢迎访问）博主原创文章，未经博主允许不得转载。</p>
</blockquote>
<h4 id="现在转眼都十三了，大家都工作了，自己确还没有在家里闲得慌于是就做个App，谁知道就遇到了Activity间传递实例以及List数据的问题。网上同类型的文章很多，我写只是为了做个笔记预防忘记（其他的我觉得进入不了状态，还是自己的思维好理解一些）。"><a href="#现在转眼都十三了，大家都工作了，自己确还没有在家里闲得慌于是就做个App，谁知道就遇到了Activity间传递实例以及List数据的问题。网上同类型的文章很多，我写只是为了做个笔记预防忘记（其他的我觉得进入不了状态，还是自己的思维好理解一些）。" class="headerlink" title="现在转眼都十三了，大家都工作了，自己确还没有在家里闲得慌于是就做个App，谁知道就遇到了Activity间传递实例以及List数据的问题。网上同类型的文章很多，我写只是为了做个笔记预防忘记（其他的我觉得进入不了状态，还是自己的思维好理解一些）。"></a>现在转眼都十三了，大家都工作了，自己确还没有在家里闲得慌于是就做个App，谁知道就遇到了Activity间传递实例以及List<t>数据的问题。网上同类型的文章很多，我写只是为了做个笔记预防忘记（其他的我觉得进入不了状态，还是自己的思维好理解一些）。</t></h4><h4 id="废话不多说下面正题。"><a href="#废话不多说下面正题。" class="headerlink" title="废话不多说下面正题。"></a>废话不多说下面正题。</h4><h4 id="要实现上面的需求有几种方式："><a href="#要实现上面的需求有几种方式：" class="headerlink" title="要实现上面的需求有几种方式："></a>要实现上面的需求有几种方式：</h4><h4 id="1-定义全局静态变量，由一个静态变量集合类管理，至于安全方面，可以把控访问方式，比如验证访问，不过相对来说感觉比较麻烦。"><a href="#1-定义全局静态变量，由一个静态变量集合类管理，至于安全方面，可以把控访问方式，比如验证访问，不过相对来说感觉比较麻烦。" class="headerlink" title="1.定义全局静态变量，由一个静态变量集合类管理，至于安全方面，可以把控访问方式，比如验证访问，不过相对来说感觉比较麻烦。"></a>1.定义全局静态变量，由一个静态变量集合类管理，至于安全方面，可以把控访问方式，比如验证访问，不过相对来说感觉比较麻烦。</h4><h4 id="2-Application中设置一个属性，公开读取。"><a href="#2-Application中设置一个属性，公开读取。" class="headerlink" title="2. Application中设置一个属性，公开读取。"></a>2. Application中设置一个属性，公开读取。</h4><h4 id="3-使用Serializable序列化我们需要传递的数据，再通过Intent的putExtra-name-value-方法添加到Intent中，再接收活动中使用Intent的getSerializableExtra-name-方法获取到相对应数据。"><a href="#3-使用Serializable序列化我们需要传递的数据，再通过Intent的putExtra-name-value-方法添加到Intent中，再接收活动中使用Intent的getSerializableExtra-name-方法获取到相对应数据。" class="headerlink" title="3.使用Serializable序列化我们需要传递的数据，再通过Intent的putExtra(name,value);方法添加到Intent中，再接收活动中使用Intent的getSerializableExtra(name);方法获取到相对应数据。"></a>3.使用Serializable序列化我们需要传递的数据，再通过Intent的putExtra(name,value);方法添加到Intent中，再接收活动中使用Intent的getSerializableExtra(name);方法获取到相对应数据。</h4><h4 id="下面我们就试试第三种："><a href="#下面我们就试试第三种：" class="headerlink" title="下面我们就试试第三种："></a>下面我们就试试第三种：</h4><h4 id="直接上代码（需要传递的数据的类定义需要修改，让他有Serializable接口，才能实现数据的序列化）"><a href="#直接上代码（需要传递的数据的类定义需要修改，让他有Serializable接口，才能实现数据的序列化）" class="headerlink" title="直接上代码（需要传递的数据的类定义需要修改，让他有Serializable接口，才能实现数据的序列化）"></a>直接上代码（需要传递的数据的类定义需要修改，让他有Serializable接口，才能实现数据的序列化）</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div><div class="line">117</div><div class="line">118</div><div class="line">119</div><div class="line">120</div><div class="line">121</div><div class="line">122</div><div class="line">123</div><div class="line">124</div><div class="line">125</div><div class="line">126</div><div class="line">127</div><div class="line">128</div><div class="line">129</div><div class="line">130</div><div class="line">131</div><div class="line">132</div><div class="line">133</div><div class="line">134</div><div class="line">135</div><div class="line">136</div><div class="line">137</div><div class="line">138</div><div class="line">139</div><div class="line">140</div><div class="line">141</div><div class="line">142</div><div class="line">143</div><div class="line">144</div><div class="line">145</div><div class="line">146</div><div class="line">147</div><div class="line">148</div><div class="line">149</div><div class="line">150</div><div class="line">151</div><div class="line">152</div><div class="line">153</div><div class="line">154</div><div class="line">155</div><div class="line">156</div><div class="line">157</div><div class="line">158</div><div class="line">159</div><div class="line">160</div><div class="line">161</div><div class="line">162</div><div class="line">163</div><div class="line">164</div><div class="line">165</div><div class="line">166</div><div class="line">167</div><div class="line">168</div><div class="line">169</div><div class="line">170</div><div class="line">171</div><div class="line">172</div><div class="line">173</div><div class="line">174</div><div class="line">175</div><div class="line">176</div><div class="line">177</div><div class="line">178</div><div class="line">179</div><div class="line">180</div><div class="line">181</div><div class="line">182</div><div class="line">183</div><div class="line">184</div><div class="line">185</div><div class="line">186</div><div class="line">187</div><div class="line">188</div><div class="line">189</div><div class="line">190</div><div class="line">191</div><div class="line">192</div><div class="line">193</div><div class="line">194</div><div class="line">195</div><div class="line">196</div><div class="line">197</div><div class="line">198</div><div class="line">199</div><div class="line">200</div><div class="line">201</div><div class="line">202</div><div class="line">203</div><div class="line">204</div><div class="line">205</div><div class="line">206</div><div class="line">207</div><div class="line">208</div><div class="line">209</div><div class="line">210</div><div class="line">211</div><div class="line">212</div><div class="line">213</div><div class="line">214</div><div class="line">215</div><div class="line">216</div><div class="line">217</div><div class="line">218</div><div class="line">219</div><div class="line">220</div><div class="line">221</div><div class="line">222</div><div class="line">223</div><div class="line">224</div><div class="line">225</div><div class="line">226</div><div class="line">227</div><div class="line">228</div><div class="line">229</div><div class="line">230</div><div class="line">231</div><div class="line">232</div><div class="line">233</div><div class="line">234</div><div class="line">235</div><div class="line">236</div><div class="line">237</div><div class="line">238</div><div class="line">239</div><div class="line">240</div><div class="line">241</div><div class="line">242</div><div class="line">243</div><div class="line">244</div><div class="line">245</div><div class="line">246</div><div class="line">247</div><div class="line">248</div><div class="line">249</div><div class="line">250</div><div class="line">251</div><div class="line">252</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> winter.zxb.smilesb101.easysyrinx.Data.SyrinxInfo;  </div><div class="line"></div><div class="line"><span class="keyword">import</span> java.io.Serializable;  </div><div class="line"><span class="keyword">import</span> java.util.ArrayList;  </div><div class="line"></div><div class="line"><span class="comment">/**</span></div><div class="line"> * 项目名称：EasySyrinx</div><div class="line"> * 类描述：希芸物品信息类，接口后面的是关键我们需要这个接口才能让数据序列化</div><div class="line"> * 创建人：SmileSB101</div><div class="line"> * 创建时间：2017/2/1 0001 22:29</div><div class="line"> * 修改人：Administrator</div><div class="line"> * 修改时间：2017/2/1 0001 22:29</div><div class="line"> * 修改备注：</div><div class="line"> */  </div><div class="line"></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">SyrinxItem</span> <span class="keyword">implements</span> <span class="title">Serializable</span></span>&#123;  </div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 用于进行键值对封装时作为键</div><div class="line">     */  </div><div class="line">    <span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">static</span> String NAME_STRING = <span class="string">"name"</span>;  </div><div class="line">    <span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">static</span> String CODE_STRING = <span class="string">"code"</span>;  </div><div class="line">    <span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">static</span> String KIND_STRING = <span class="string">"kind"</span>;  </div><div class="line">    <span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">static</span> String SERIES_STRING = <span class="string">"series"</span>;  </div><div class="line">    <span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">static</span> String IN_PRICE_STRING = <span class="string">"in_price"</span>;  </div><div class="line">    <span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">static</span> String OUT_PRICE_STRING = <span class="string">"out_price"</span>;  </div><div class="line">    <span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">static</span> String INTRODUCE_STRING = <span class="string">"introduce"</span>;  </div><div class="line">    <span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">static</span> String TAGLIST_STRING = <span class="string">"tagList"</span>;  </div><div class="line">    <span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">static</span> String FREEPOST_STRING = <span class="string">"freePost"</span>;  </div><div class="line"></div><div class="line"></div><div class="line">    <span class="keyword">private</span> String name;  </div><div class="line">    <span class="keyword">private</span> String code;  </div><div class="line">    <span class="keyword">private</span> String kind;  </div><div class="line">    <span class="keyword">private</span> String format;  </div><div class="line">    <span class="keyword">private</span> String series;  </div><div class="line">    <span class="keyword">private</span> <span class="keyword">float</span> in_price;  </div><div class="line">    <span class="keyword">private</span> <span class="keyword">float</span> out_price;  </div><div class="line">    <span class="keyword">private</span> String introduce;  </div><div class="line">    <span class="keyword">private</span> ArrayList&lt;String&gt; tagList;  </div><div class="line">    <span class="keyword">private</span> <span class="keyword">boolean</span> freePost;  </div><div class="line"></div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="title">SyrinxItem</span><span class="params">()</span></span>&#123;  </div><div class="line">        <span class="keyword">this</span>.tagList = <span class="keyword">new</span> ArrayList&lt;&gt;();  </div><div class="line">        <span class="keyword">this</span>.in_price = <span class="number">0</span>;  </div><div class="line">        <span class="keyword">this</span>.out_price = <span class="number">0</span>;  </div><div class="line">        freePost = <span class="keyword">false</span>;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 全参数构造方法</div><div class="line">     * <span class="doctag">@param</span> code 商品编号</div><div class="line">     * <span class="doctag">@param</span> name 商品名称</div><div class="line">     * <span class="doctag">@param</span> kind 商品种类</div><div class="line">     * <span class="doctag">@param</span> format 商品规格</div><div class="line">     * <span class="doctag">@param</span> series 商品系列</div><div class="line">     * <span class="doctag">@param</span> in_price 商品</div><div class="line">     * <span class="doctag">@param</span> out_price 卖价</div><div class="line">     * <span class="doctag">@param</span> introduce 介绍</div><div class="line">     * <span class="doctag">@param</span> tagList 标签列表</div><div class="line">     * <span class="doctag">@param</span> freePost 包邮</div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="title">SyrinxItem</span><span class="params">(String code,String name,String kind,String format,String series,<span class="keyword">float</span> in_price,<span class="keyword">float</span> out_price,String introduce,ArrayList&lt;String&gt; tagList,<span class="keyword">boolean</span> freePost)</span></span>&#123;  </div><div class="line">        <span class="keyword">this</span>.code = code;  </div><div class="line">        <span class="keyword">this</span>.name = name;  </div><div class="line">        <span class="keyword">this</span>.kind = kind;  </div><div class="line">        <span class="keyword">this</span>.format = format;  </div><div class="line">        <span class="keyword">this</span>.series = series;  </div><div class="line">        <span class="keyword">this</span>.in_price = in_price;  </div><div class="line">        <span class="keyword">this</span>.out_price = out_price;  </div><div class="line">        <span class="keyword">this</span>.introduce = introduce;  </div><div class="line">        <span class="keyword">this</span>.tagList = tagList;  </div><div class="line">        <span class="keyword">this</span>.freePost = freePost;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getFormat</span><span class="params">()</span></span>&#123;  </div><div class="line">        <span class="keyword">return</span> format;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setFormat</span><span class="params">(String format)</span></span>&#123;  </div><div class="line">        <span class="keyword">this</span>.format = format;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 获取是否包邮</div><div class="line">     * <span class="doctag">@return</span></div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">isFreePost</span><span class="params">()</span></span>&#123;  </div><div class="line">        <span class="keyword">return</span> freePost?<span class="string">"包邮"</span>:<span class="string">"不包邮"</span>;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 设置是否包邮</div><div class="line">     * <span class="doctag">@param</span> freePost</div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setFreePost</span><span class="params">(<span class="keyword">boolean</span> freePost)</span></span>&#123;  </div><div class="line">        <span class="keyword">this</span>.freePost = freePost;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 获取系列名称</div><div class="line">     * <span class="doctag">@return</span></div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getSeries</span><span class="params">()</span></span>&#123;  </div><div class="line">        <span class="keyword">return</span> series;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 设置系列名称</div><div class="line">     * <span class="doctag">@param</span> series</div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setSeries</span><span class="params">(String series)</span></span>&#123;  </div><div class="line">        <span class="keyword">this</span>.series = series;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 获取类型（商品颜色或者分类等）</div><div class="line">     * <span class="doctag">@return</span></div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getKind</span><span class="params">()</span></span>&#123;  </div><div class="line">        <span class="keyword">return</span> kind;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 设置类型（商品颜色或者分类等）</div><div class="line">     * <span class="doctag">@param</span> kind</div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setKind</span><span class="params">(String kind)</span></span>&#123;  </div><div class="line">        <span class="keyword">this</span>.kind = kind;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 获取卖出价格</div><div class="line">     * <span class="doctag">@return</span></div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">float</span> <span class="title">getOut_price</span><span class="params">()</span></span>&#123;  </div><div class="line">        <span class="keyword">return</span> out_price;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 设置卖出价格</div><div class="line">     * <span class="doctag">@param</span> out_price</div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setOut_price</span><span class="params">(<span class="keyword">float</span> out_price)</span></span>&#123;  </div><div class="line">        <span class="keyword">this</span>.out_price = out_price;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 获取物品名称</div><div class="line">     * <span class="doctag">@return</span> 物品名称</div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getName</span><span class="params">()</span></span>&#123;  </div><div class="line">        <span class="keyword">return</span> name;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 设置物品名称</div><div class="line">     * <span class="doctag">@param</span> name 物品民称</div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setName</span><span class="params">(String name)</span></span>&#123;  </div><div class="line">        <span class="keyword">this</span>.name = name;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 获取商品编号</div><div class="line">     * <span class="doctag">@return</span> 商品编号</div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getCode</span><span class="params">()</span></span>&#123;  </div><div class="line">        <span class="keyword">return</span> code;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 设置商品编号</div><div class="line">     * <span class="doctag">@param</span> code</div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setCode</span><span class="params">(String code)</span></span>&#123;  </div><div class="line">        <span class="keyword">this</span>.code = code;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 获取商品进价</div><div class="line">     * <span class="doctag">@return</span></div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">float</span> <span class="title">getIn_price</span><span class="params">()</span></span>&#123;  </div><div class="line">        <span class="keyword">return</span> in_price;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 设置商品进价</div><div class="line">     * <span class="doctag">@param</span> in_price</div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setIn_price</span><span class="params">(<span class="keyword">float</span> in_price)</span></span>&#123;  </div><div class="line">        <span class="keyword">this</span>.in_price = in_price;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 获取商品介绍</div><div class="line">     * <span class="doctag">@return</span></div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getIntroduce</span><span class="params">()</span></span>&#123;  </div><div class="line">        <span class="keyword">return</span> introduce;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 设置商品介绍</div><div class="line">     * <span class="doctag">@param</span> introduce</div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setIntroduce</span><span class="params">(String introduce)</span></span>&#123;  </div><div class="line">        <span class="keyword">this</span>.introduce = introduce;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 获取商品标签（特性）</div><div class="line">     * <span class="doctag">@return</span></div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> ArrayList&lt;String&gt; <span class="title">getTagList</span><span class="params">()</span></span>&#123;  </div><div class="line">        <span class="keyword">return</span> tagList;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 设置商品特性</div><div class="line">     * <span class="doctag">@param</span> tagList</div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setTagList</span><span class="params">(ArrayList&lt;String&gt; tagList)</span></span>&#123;  </div><div class="line">        <span class="keyword">this</span>.tagList = tagList;  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 设置商品特性</div><div class="line">     * <span class="doctag">@param</span> tag</div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setTagList</span><span class="params">(String tag)</span>  </span></div><div class="line">    &#123;  </div><div class="line">        <span class="keyword">this</span>.tagList.add(tag);  </div><div class="line">    &#125;  </div><div class="line"></div><div class="line">    <span class="comment">/**</span></div><div class="line">     * 获取此实例的json字符串</div><div class="line">     * <span class="doctag">@return</span></div><div class="line">     */  </div><div class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">ToJsonString</span><span class="params">()</span>  </span></div><div class="line">    &#123;  </div><div class="line">        <span class="keyword">return</span> <span class="string">"Syrinx ["</span>+NAME_STRING+<span class="string">"="</span>+getName()+<span class="string">","</span>  </div><div class="line">                +CODE_STRING+<span class="string">"="</span>+getCode()+<span class="string">","</span>  </div><div class="line">                +KIND_STRING+<span class="string">"="</span>+getKind()+<span class="string">","</span>  </div><div class="line">                +SERIES_STRING+<span class="string">"="</span>+getSeries()+<span class="string">","</span>  </div><div class="line">                +IN_PRICE_STRING+<span class="string">"="</span>+getIn_price()+<span class="string">","</span>  </div><div class="line">                +OUT_PRICE_STRING+<span class="string">"="</span>+getOut_price()+<span class="string">","</span>  </div><div class="line">                +INTRODUCE_STRING+<span class="string">"="</span>+getIntroduce()+<span class="string">","</span>  </div><div class="line">                +TAGLIST_STRING+<span class="string">"="</span>+getTagList()+<span class="string">","</span>  </div><div class="line">                +freePost+<span class="string">"="</span>+isFreePost()+<span class="string">"]"</span>;  </div><div class="line">    &#125;  </div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h4 id="上一个活动中-在这里list是ArrayList-当然里面存储了数据。series是另外一个序列化的单个对象。"><a href="#上一个活动中-在这里list是ArrayList-当然里面存储了数据。series是另外一个序列化的单个对象。" class="headerlink" title="上一个活动中,在这里list是ArrayList();当然里面存储了数据。series是另外一个序列化的单个对象。"></a>上一个活动中,在这里list是ArrayList<syrinxitem>();当然里面存储了数据。series是另外一个序列化的单个对象。</syrinxitem></h4><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">Intent intent = <span class="keyword">new</span> Intent(activity,SyrinxItemRecycleViewActivity.class);  </div><div class="line">                intent.putExtra(SyrinxItemRecycleViewActivity.SYRINXLIST_VALUE,list);  </div><div class="line">                intent.putExtra(SyrinxItemRecycleViewActivity.SYRINXSERIES_VALUE,series);  </div><div class="line">                activity.startActivity(intent);</div></pre></td></tr></table></figure>
<h4 id="接收的活动中-使用getIntet-获取到Intent，然后通过Intent中的getSerializableExtra-name-方法来获取到数据，注意强制类型转换。"><a href="#接收的活动中-使用getIntet-获取到Intent，然后通过Intent中的getSerializableExtra-name-方法来获取到数据，注意强制类型转换。" class="headerlink" title="接收的活动中,使用getIntet();获取到Intent，然后通过Intent中的getSerializableExtra(name);方法来获取到数据，注意强制类型转换。"></a>接收的活动中,使用getIntet();获取到Intent，然后通过Intent中的getSerializableExtra(name);方法来获取到数据，注意强制类型转换。</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> winter.zxb.smilesb101.easysyrinx.UI.Activity;  </div><div class="line"></div><div class="line"><span class="keyword">import</span> android.content.Context;  </div><div class="line"><span class="keyword">import</span> android.content.Intent;  </div><div class="line"><span class="keyword">import</span> android.support.v7.app.AppCompatActivity;  </div><div class="line"><span class="keyword">import</span> android.os.Bundle;  </div><div class="line"><span class="keyword">import</span> android.support.v7.widget.LinearLayoutManager;  </div><div class="line"><span class="keyword">import</span> android.support.v7.widget.RecyclerView;  </div><div class="line"><span class="keyword">import</span> android.util.Log;  </div><div class="line"><span class="keyword">import</span> android.view.View;  </div><div class="line"></div><div class="line"><span class="keyword">import</span> java.util.ArrayList;  </div><div class="line"></div><div class="line"><span class="keyword">import</span> winter.zxb.smilesb101.easysyrinx.Data.SyrinxInfo.SyrinxItem;  </div><div class="line"><span class="keyword">import</span> winter.zxb.smilesb101.easysyrinx.Data.SyrinxInfo.SyrinxItemRecycleViewAdapter;  </div><div class="line"><span class="keyword">import</span> winter.zxb.smilesb101.easysyrinx.Data.SyrinxInfo.SyrinxSeries;  </div><div class="line"><span class="keyword">import</span> winter.zxb.smilesb101.easysyrinx.R;  </div><div class="line"></div><div class="line"><span class="comment">/**</span></div><div class="line"> * 希芸产品信息的展示活动</div><div class="line"> */  </div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">SyrinxItemRecycleViewActivity</span> <span class="keyword">extends</span> <span class="title">AppCompatActivity</span></span>&#123;  </div><div class="line"></div><div class="line">    <span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">static</span> String SYRINXLIST_VALUE = <span class="string">"SYRINXLIST"</span>;  </div><div class="line">    <span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">static</span> String SYRINXSERIES_VALUE = <span class="string">"SYRINXSERIES"</span>;  </div><div class="line">    <span class="keyword">private</span> <span class="keyword">final</span> <span class="keyword">static</span> String TAG = <span class="string">"SyrinxItemActivity"</span>;  </div><div class="line"></div><div class="line">    <span class="keyword">private</span> View rootView;  </div><div class="line">    <span class="keyword">private</span> RecyclerView recyclerView;  </div><div class="line">    <span class="keyword">private</span> Context context;  </div><div class="line">    <span class="keyword">private</span> SyrinxItemRecycleViewAdapter itemRecycleViewAdapter;  </div><div class="line">    <span class="keyword">private</span> SyrinxSeries syrinxSeries;  </div><div class="line">    <span class="keyword">private</span> ArrayList&lt;SyrinxItem&gt; syrinxItems;  </div><div class="line"></div><div class="line">    <span class="meta">@Override</span>  </div><div class="line">    <span class="function"><span class="keyword">protected</span> <span class="keyword">void</span> <span class="title">onCreate</span><span class="params">(Bundle savedInstanceState)</span></span>&#123;  </div><div class="line">        <span class="keyword">super</span>.onCreate(savedInstanceState);  </div><div class="line">        setContentView(R.layout.syrinxitem_recycleview_layout);  </div><div class="line">        Intent intent = getIntent();  </div><div class="line">        syrinxItems = (ArrayList&lt;SyrinxItem&gt;)intent.getSerializableExtra(SYRINXLIST_VALUE);  </div><div class="line">        syrinxSeries = (SyrinxSeries)intent.getSerializableExtra(SYRINXSERIES_VALUE);  </div><div class="line"></div><div class="line">        recyclerView = (RecyclerView)findViewById(R.id.syrinxitem_layout_recycleView);  </div><div class="line">        LinearLayoutManager layoutmanager = <span class="keyword">new</span> LinearLayoutManager(<span class="keyword">this</span>);  </div><div class="line">        recyclerView.setLayoutManager(layoutmanager);  </div><div class="line">        itemRecycleViewAdapter = <span class="keyword">new</span> SyrinxItemRecycleViewAdapter(syrinxItems,<span class="keyword">this</span>);  </div><div class="line">        recyclerView.setAdapter(itemRecycleViewAdapter);  </div><div class="line">        Log.i(TAG,<span class="string">"onCreate: huodongchuangjian"</span>);  </div><div class="line">    &#125;  </div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h4 id="下面上效果图-主活动中：（点击任意一个item进入下个活动）"><a href="#下面上效果图-主活动中：（点击任意一个item进入下个活动）" class="headerlink" title="下面上效果图,主活动中：（点击任意一个item进入下个活动）"></a>下面上效果图,主活动中：（点击任意一个item进入下个活动）</h4><p><img src="http://img.blog.csdn.net/20170209150029848?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjEyNjU5MTU=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="image"></p>
<h4 id="接收活动中：可以看到成功的接收到了来自上一个活动的List以及单个对象的数据"><a href="#接收活动中：可以看到成功的接收到了来自上一个活动的List以及单个对象的数据" class="headerlink" title="接收活动中：可以看到成功的接收到了来自上一个活动的List以及单个对象的数据"></a>接收活动中：可以看到成功的接收到了来自上一个活动的List<t>以及单个对象的数据</t></h4><p><img src="http://img.blog.csdn.net/20170209150034832?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjEyNjU5MTU=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="image"></p>
<h3 id="总结：我们想要传递List或者某个实例对象数据很简单，只需要那个需要传递的实例定义时有接口Serializable，以及取数据的时候使用getSerializableExtra-name-方法就可以了。"><a href="#总结：我们想要传递List或者某个实例对象数据很简单，只需要那个需要传递的实例定义时有接口Serializable，以及取数据的时候使用getSerializableExtra-name-方法就可以了。" class="headerlink" title="总结：我们想要传递List或者某个实例对象数据很简单，只需要那个需要传递的实例定义时有接口Serializable，以及取数据的时候使用getSerializableExtra(name);方法就可以了。"></a><strong>总结：我们想要传递List<t>或者某个实例对象数据很简单，只需要那个需要传递的实例定义时有接口Serializable，以及取数据的时候使用getSerializableExtra(name);方法就可以了。</t></strong></h3>
      
    </div>

    <div>
      
        
<div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center">
    <img id="wechat_subscriber_qcode" src="http://on792ofrp.bkt.clouddn.com/17-3-22/89969433-file_1490159480281_107f8.jpg" alt="WinterSmileSB101 wechat" style="width: 200px; max-width: 100%;"/>
    <div>欢迎关注我的微信公众帐号，不定期推送各种技术文章</div>
</div>


      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <ul class="post-copyright">
    <li class="post-copyright-author">
      <strong>本文作者：</strong>
      WinterSmileSB101
    </li>
    <li class="post-copyright-link">
      <strong>本文链接：</strong>
      <a href="http://WinterSmileSB101.online/2017/03/22/17开年第一篇活动传递对象/" title="17开年第一篇Activity之间传递 List<T> 以及 T 对象类型数据的方法">http://WinterSmileSB101.online/2017/03/22/17开年第一篇活动传递对象/</a>
    </li>
    <li class="post-copyright-license">
      <strong>版权声明： </strong>
      本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/" rel="external nofollow" target="_blank">CC BY-NC-SA 3.0</a> 许可协议。转载请注明出处！
    </li>
  </ul>


      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Android/" rel="tag"># Android</a>
          
            <a href="/tags/Activity/" rel="tag"># Activity</a>
          
            <a href="/tags/活动传递对象/" rel="tag"># 活动传递对象</a>
          
            <a href="/tags/活动传递-List/" rel="tag"># 活动传递 List</a>
          
        </div>
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/03/22/拿来就用的圆形图片控件/" rel="next" title="Android 拿来就用的圆形图片控件">
                <i class="fa fa-chevron-left"></i> Android 拿来就用的圆形图片控件
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/03/22/Android利用Gson生成或解析json/" rel="prev" title="Android利用Gson生成或解析json">
                Android利用Gson生成或解析json <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <div class="ds-share flat" data-thread-key="2017/03/22/17开年第一篇活动传递对象/"
     data-title="17开年第一篇Activity之间传递 List<T> 以及 T 对象类型数据的方法"
     data-content=""
     data-url="http://WinterSmileSB101.online/2017/03/22/17开年第一篇活动传递对象/">
  <div class="ds-share-inline">
    <ul  class="ds-share-icons-16">

      <li data-toggle="ds-share-icons-more"><a class="ds-more" href="javascript:void(0);">分享到：</a></li>
      <li><a class="ds-weibo" href="javascript:void(0);" data-service="weibo">微博</a></li>
      <li><a class="ds-qzone" href="javascript:void(0);" data-service="qzone">QQ空间</a></li>
      <li><a class="ds-qqt" href="javascript:void(0);" data-service="qqt">腾讯微博</a></li>
      <li><a class="ds-wechat" href="javascript:void(0);" data-service="wechat">微信</a></li>

    </ul>
    <div class="ds-share-icons-more">
    </div>
  </div>
</div>
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2017/03/22/17开年第一篇活动传递对象/"
           data-title="17开年第一篇Activity之间传递 List<T> 以及 T 对象类型数据的方法" data-url="http://WinterSmileSB101.online/2017/03/22/17开年第一篇活动传递对象/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="http://on792ofrp.bkt.clouddn.com/17-3-22/29073846-file_1490159480452_d2de.jpg"
               alt="WinterSmileSB101" />
          <p class="site-author-name" itemprop="name">WinterSmileSB101</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
           
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">52</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">26</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">113</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="http://blog.csdn.net/qq_21265915/rss/list" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <!--自己写的社交链接-->
        <div class="links-of-author motion-element">
         <span class="links-of-author-item">
         <a href="https://github.com/WinterSmileSB101" title="Github">
         <i class="fa fa-fw fa-github fa-lg"></i>
         </a>
         </span>
         <span class="links-of-author-item">
                  <a href="http://weibo.com/5602632941/profile?rightmod=1&wvr=6&mod=personinfo&is_all=1" title="微博">
                  <i class="fa fa-fw fa-weibo fa-lg"></i>
                  </a>
                  </span>
         <span class="links-of-author-item">
         <a href="http://www.jianshu.com/users/73344bc7e890/timeline" title="简书">
         <i class="fa fa-fw fa-bookmark fa-lg"></i>
         </a>
         </span>
<br />
        <span class="links-of-author-item">
                 <a href="https://www.douban.com/people/159359470/" title="豆瓣">
                 <i class="fa fa-fw fa-newspaper-o fa-lg"></i>
                 </a>
                 </span>
        <span class="links-of-author-item">
                 <a href="http://blog.csdn.net/qq_21265915" title="CSDN博客">
                 <i class="fa fa-fw fa-bug fa-lg"></i>
                 </a>
                 </span>
        </div>
        <!--自己写的社交链接-->

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#现在转眼都十三了，大家都工作了，自己确还没有在家里闲得慌于是就做个App，谁知道就遇到了Activity间传递实例以及List数据的问题。网上同类型的文章很多，我写只是为了做个笔记预防忘记（其他的我觉得进入不了状态，还是自己的思维好理解一些）。"><span class="nav-number">1.</span> <span class="nav-text">现在转眼都十三了，大家都工作了，自己确还没有在家里闲得慌于是就做个App，谁知道就遇到了Activity间传递实例以及List数据的问题。网上同类型的文章很多，我写只是为了做个笔记预防忘记（其他的我觉得进入不了状态，还是自己的思维好理解一些）。</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#废话不多说下面正题。"><span class="nav-number">2.</span> <span class="nav-text">废话不多说下面正题。</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#要实现上面的需求有几种方式："><span class="nav-number">3.</span> <span class="nav-text">要实现上面的需求有几种方式：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-定义全局静态变量，由一个静态变量集合类管理，至于安全方面，可以把控访问方式，比如验证访问，不过相对来说感觉比较麻烦。"><span class="nav-number">4.</span> <span class="nav-text">1.定义全局静态变量，由一个静态变量集合类管理，至于安全方面，可以把控访问方式，比如验证访问，不过相对来说感觉比较麻烦。</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-Application中设置一个属性，公开读取。"><span class="nav-number">5.</span> <span class="nav-text">2. Application中设置一个属性，公开读取。</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-使用Serializable序列化我们需要传递的数据，再通过Intent的putExtra-name-value-方法添加到Intent中，再接收活动中使用Intent的getSerializableExtra-name-方法获取到相对应数据。"><span class="nav-number">6.</span> <span class="nav-text">3.使用Serializable序列化我们需要传递的数据，再通过Intent的putExtra(name,value);方法添加到Intent中，再接收活动中使用Intent的getSerializableExtra(name);方法获取到相对应数据。</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#下面我们就试试第三种："><span class="nav-number">7.</span> <span class="nav-text">下面我们就试试第三种：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#直接上代码（需要传递的数据的类定义需要修改，让他有Serializable接口，才能实现数据的序列化）"><span class="nav-number">8.</span> <span class="nav-text">直接上代码（需要传递的数据的类定义需要修改，让他有Serializable接口，才能实现数据的序列化）</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#上一个活动中-在这里list是ArrayList-当然里面存储了数据。series是另外一个序列化的单个对象。"><span class="nav-number">9.</span> <span class="nav-text">上一个活动中,在这里list是ArrayList();当然里面存储了数据。series是另外一个序列化的单个对象。</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#接收的活动中-使用getIntet-获取到Intent，然后通过Intent中的getSerializableExtra-name-方法来获取到数据，注意强制类型转换。"><span class="nav-number">10.</span> <span class="nav-text">接收的活动中,使用getIntet();获取到Intent，然后通过Intent中的getSerializableExtra(name);方法来获取到数据，注意强制类型转换。</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#下面上效果图-主活动中：（点击任意一个item进入下个活动）"><span class="nav-number">11.</span> <span class="nav-text">下面上效果图,主活动中：（点击任意一个item进入下个活动）</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#接收活动中：可以看到成功的接收到了来自上一个活动的List以及单个对象的数据"><span class="nav-number">12.</span> <span class="nav-text">接收活动中：可以看到成功的接收到了来自上一个活动的List以及单个对象的数据</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#总结：我们想要传递List或者某个实例对象数据很简单，只需要那个需要传递的实例定义时有接口Serializable，以及取数据的时候使用getSerializableExtra-name-方法就可以了。"><span class="nav-number"></span> <span class="nav-text">总结：我们想要传递List或者某个实例对象数据很简单，只需要那个需要传递的实例定义时有接口Serializable，以及取数据的时候使用getSerializableExtra(name);方法就可以了。</span></a></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      
        <div class="back-to-top">
          <i class="fa fa-arrow-up"></i>
          
            <span id="scrollpercent"><span>0</span>%</span>
          
        </div>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2017.3.20 - 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Powered By - WinterSmileSB101</span>
</div>


<div class="powered-by">
    个人专属
</div>

<div class="theme-info">
  博客 -
  WinterSmileSB101
</div>


        

        
      </div>
    </footer>

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>

  
  <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"wintersmilesb101"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
      
      <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
      <script src="/js/src/hook-duoshuo.js?v=5.1.0"></script>
    
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  
















  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
      search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.popup').toggle();
    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';
      $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = $( "entry", xmlResponse ).map(function() {
            return {
              title: $( "title", this ).text(),
              content: $("content",this).text(),
              url: $( "url" , this).text()
            };
          }).get();
          var $input = document.getElementById(search_id);
          var $resultContent = document.getElementById(content_id);
          $input.addEventListener('input', function(){
            var matchcounts = 0;
            var str='<ul class=\"search-result-list\">';
            var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
            $resultContent.innerHTML = "";
            if (this.value.trim().length > 1) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var content_index = [];
                var data_title = data.title.trim().toLowerCase();
                var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                var data_url = decodeURIComponent(data.url);
                var index_title = -1;
                var index_content = -1;
                var first_occur = -1;
                // only match artiles with not empty titles and contents
                if(data_title != '') {
                  keywords.forEach(function(keyword, i) {
                    index_title = data_title.indexOf(keyword);
                    index_content = data_content.indexOf(keyword);
                    if( index_title >= 0 || index_content >= 0 ){
                      isMatch = true;
                      if (i == 0) {
                        first_occur = index_content;
                      }
                    }

                  });
                }
                // show search results
                if (isMatch) {
                  matchcounts += 1;
                  str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                  var content = data.content.trim().replace(/<[^>]+>/g,"");
                  if (first_occur >= 0) {
                    // cut out 100 characters
                    var start = first_occur - 20;
                    var end = first_occur + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if(start == 0){
                      end = 50;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    var match_content = content.substring(start, end);
                    // highlight all keywords
                    keywords.forEach(function(keyword){
                      var regS = new RegExp(keyword, "gi");
                      match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                    });

                    str += "<p class=\"search-result\">" + match_content +"...</p>"
                  }
                  str += "</li>";
                }
              })};
            str += "</ul>";
            if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
            if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
            $resultContent.innerHTML = str;
          });
          proceedsearch();
        }
      });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
  <script>AV.initialize("cOFi0858xVYxKW1wnErxqEra-gzGzoHsz", "7LaqqR82XnjzTbkv5eCKw5aW");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  

</body>
</html>
